Skip to content

Scope a boundary's children to its pending streamed range - #5360

Merged
JoviDeCroock merged 3 commits into
mainfrom
pending-range-hydration
Nov 18, 2026
Merged

JoviDeCroock merged 3 commits into
mainfrom
pending-range-hydration

Conversation

@JoviDeCroock

Copy link
Copy Markdown
Member

A streamed Suspense range can still hold its fallback when the client hydrates it: the server is still streaming the content (<!--$s?:id-->), or gave up on it (<!--$s!:id-->). When the client renders the real content there, hydration adopts the fallback's elements and keeps their attributes, or adopts an element of a later sibling, which ends in duplicated ids and dead handlers.

A boundary in front of such a range now gives its children only that range to adopt from, and they diff the attributes of what they adopt. Resolved ranges hydrate as before.

Needs the $s? marker from preactjs/preact-render-to-string#496.

This PR was authored by Fable 5.2.

@github-actions

github-actions Bot commented Nov 13, 2026 •

Copy link
Copy Markdown

📊 Tachometer Benchmark Results

Summary

duration

  • create10k: unsure 🔍 -3% - +1% (-23.25ms - +10.68ms)
    preact-local vs preact-main
  • filter-list: unsure 🔍 -0% - +0% (-0.06ms - +0.02ms)
    preact-local vs preact-main
  • hydrate1k: unsure 🔍 -1% - +3% (-0.28ms - +1.25ms)
    preact-local vs preact-main
  • many-updates: unsure 🔍 -2% - +4% (-0.40ms - +0.59ms)
    preact-local vs preact-main
  • replace1k: unsure 🔍 -6% - -0% (-3.52ms - +0.01ms)
    preact-local vs preact-main
  • text-update: unsure 🔍 -7% - +3% (-0.10ms - +0.05ms)
    preact-local vs preact-main
  • todo: unsure 🔍 -3% - +2% (-0.56ms - +0.35ms)
    preact-local vs preact-main
  • update10th1k: unsure 🔍 -7% - +1% (-1.96ms - +0.18ms)
    preact-local vs preact-main

usedJSHeapSize

  • create10k: unsure 🔍 +0% - +0% (+0.01ms - +0.01ms)
    preact-local vs preact-main
  • filter-list: slower ❌ 0% - 1% (0.00ms - 0.02ms)
    preact-local vs preact-main
  • hydrate1k: unsure 🔍 -3% - +6% (-0.17ms - +0.29ms)
    preact-local vs preact-main
  • many-updates: unsure 🔍 +0% - +0% (+0.00ms - +0.01ms)
    preact-local vs preact-main
  • replace1k: unsure 🔍 +0% - +0% (+0.01ms - +0.01ms)
    preact-local vs preact-main
  • text-update: unsure 🔍 -1% - +2% (-0.01ms - +0.02ms)
    preact-local vs preact-main
  • todo: slower ❌ 0% - 1% (0.01ms - 0.01ms)
    preact-local vs preact-main
  • update10th1k: unsure 🔍 -0% - +0% (-0.00ms - +0.01ms)
    preact-local vs preact-main

Results

create10k

duration

VersionAvg timevs preact-localvs preact-main
preact-local882.07ms - 891.57ms-unsure 🔍
-3% - +1%
-23.25ms - +10.68ms
preact-main876.81ms - 909.38msunsure 🔍
-1% - +3%
-10.68ms - +23.25ms
-

usedJSHeapSize

VersionAvg timevs preact-localvs preact-main
preact-local19.25ms - 19.25ms-unsure 🔍
+0% - +0%
+0.01ms - +0.01ms
preact-main19.24ms - 19.24msunsure 🔍
-0% - -0%
-0.01ms - -0.01ms
-
filter-list

duration

VersionAvg timevs preact-localvs preact-main
preact-local16.48ms - 16.55ms-unsure 🔍
-0% - +0%
-0.06ms - +0.02ms
preact-main16.52ms - 16.56msunsure 🔍
-0% - +0%
-0.02ms - +0.06ms
-

usedJSHeapSize

VersionAvg timevs preact-localvs preact-main
preact-local1.56ms - 1.58ms-slower ❌
0% - 1%
0.00ms - 0.02ms
preact-main1.56ms - 1.56msfaster ✔
0% - 1%
0.00ms - 0.02ms
-
hydrate1k
  • Browser: chrome-headless
  • Sample size: 100
  • Built by: CI #6256
  • Commit: 63e1c81

duration

VersionAvg timevs preact-localvs preact-main
preact-local47.34ms - 48.51ms-unsure 🔍
-1% - +3%
-0.28ms - +1.25ms
preact-main46.95ms - 47.94msunsure 🔍
-3% - +1%
-1.25ms - +0.28ms
-

usedJSHeapSize

VersionAvg timevs preact-localvs preact-main
preact-local5.17ms - 5.43ms-unsure 🔍
-3% - +6%
-0.17ms - +0.29ms
preact-main5.05ms - 5.43msunsure 🔍
-5% - +3%
-0.29ms - +0.17ms
-
many-updates

duration

VersionAvg timevs preact-localvs preact-main
preact-local15.89ms - 16.62ms-unsure 🔍
-2% - +4%
-0.40ms - +0.59ms
preact-main15.83ms - 16.49msunsure 🔍
-4% - +2%
-0.59ms - +0.40ms
-

usedJSHeapSize

VersionAvg timevs preact-localvs preact-main
preact-local3.76ms - 3.77ms-unsure 🔍
+0% - +0%
+0.00ms - +0.01ms
preact-main3.75ms - 3.76msunsure 🔍
-0% - -0%
-0.01ms - -0.00ms
-
replace1k
  • Browser: chrome-headless
  • Sample size: 110
  • Built by: CI #6256
  • Commit: 63e1c81

duration

VersionAvg timevs preact-localvs preact-main
preact-local58.69ms - 61.24ms-unsure 🔍
-6% - -0%
-3.52ms - +0.01ms
preact-main60.50ms - 62.94msunsure 🔍
-0% - +6%
-0.01ms - +3.52ms
-

usedJSHeapSize

VersionAvg timevs preact-localvs preact-main
preact-local3.04ms - 3.04ms-unsure 🔍
+0% - +0%
+0.01ms - +0.01ms
preact-main3.03ms - 3.03msunsure 🔍
-0% - -0%
-0.01ms - -0.01ms
-

run-warmup-0

VersionAvg timevs preact-localvs preact-main
preact-local17.27ms - 17.61ms-unsure 🔍
-2% - +1%
-0.32ms - +0.23ms
preact-main17.27ms - 17.70msunsure 🔍
-1% - +2%
-0.23ms - +0.32ms
-

run-warmup-1

VersionAvg timevs preact-localvs preact-main
preact-local19.24ms - 19.82ms-unsure 🔍
-2% - +2%
-0.34ms - +0.46ms
preact-main19.20ms - 19.74msunsure 🔍
-2% - +2%
-0.46ms - +0.34ms
-

run-warmup-2

VersionAvg timevs preact-localvs preact-main
preact-local20.90ms - 21.41ms-unsure 🔍
-1% - +2%
-0.26ms - +0.49ms
preact-main20.76ms - 21.31msunsure 🔍
-2% - +1%
-0.49ms - +0.26ms
-

run-warmup-3

VersionAvg timevs preact-localvs preact-main
preact-local22.66ms - 23.41ms-unsure 🔍
-3% - +2%
-0.73ms - +0.35ms
preact-main22.83ms - 23.61msunsure 🔍
-2% - +3%
-0.35ms - +0.73ms
-

run-warmup-4

VersionAvg timevs preact-localvs preact-main
preact-local16.54ms - 16.97ms-unsure 🔍
-0% - +4%
-0.01ms - +0.60ms
preact-main16.24ms - 16.68msunsure 🔍
-4% - +0%
-0.60ms - +0.01ms
-

run-final

VersionAvg timevs preact-localvs preact-main
preact-local21.05ms - 22.17ms-slower ❌
5% - 12%
0.98ms - 2.31ms
preact-main19.60ms - 20.33msfaster ✔
5% - 11%
0.98ms - 2.31ms
-
text-update
  • Browser: chrome-headless
  • Sample size: 240
  • Built by: CI #6256
  • Commit: 63e1c81

duration

VersionAvg timevs preact-localvs preact-main
preact-local1.36ms - 1.45ms-unsure 🔍
-7% - +3%
-0.10ms - +0.05ms
preact-main1.37ms - 1.48msunsure 🔍
-3% - +7%
-0.05ms - +0.10ms
-

usedJSHeapSize

VersionAvg timevs preact-localvs preact-main
preact-local1.01ms - 1.03ms-unsure 🔍
-1% - +2%
-0.01ms - +0.02ms
preact-main1.00ms - 1.02msunsure 🔍
-2% - +1%
-0.02ms - +0.01ms
-
todo

duration

VersionAvg timevs preact-localvs preact-main
preact-local19.35ms - 19.51ms-unsure 🔍
-3% - +2%
-0.56ms - +0.35ms
preact-main19.09ms - 19.98msunsure 🔍
-2% - +3%
-0.35ms - +0.56ms
-

usedJSHeapSize

VersionAvg timevs preact-localvs preact-main
preact-local1.29ms - 1.29ms-slower ❌
0% - 1%
0.01ms - 0.01ms
preact-main1.28ms - 1.28msfaster ✔
0% - 1%
0.01ms - 0.01ms
-
update10th1k
  • Browser: chrome-headless
  • Sample size: 150
  • Built by: CI #6256
  • Commit: 63e1c81

duration

VersionAvg timevs preact-localvs preact-main
preact-local24.97ms - 26.38ms-unsure 🔍
-7% - +1%
-1.96ms - +0.18ms
preact-main25.76ms - 27.37msunsure 🔍
-1% - +8%
-0.18ms - +1.96ms
-

usedJSHeapSize

VersionAvg timevs preact-localvs preact-main
preact-local3.00ms - 3.00ms-unsure 🔍
-0% - +0%
-0.00ms - +0.01ms
preact-main2.99ms - 3.00msunsure 🔍
-0% - +0%
-0.01ms - +0.00ms
-

tachometer-reporter-action v2 for CI

@github-actions

github-actions Bot commented Nov 13, 2026 •

Copy link
Copy Markdown

Size Change: +67 B (+0.41%)

Total Size: 16.3 kB

📦 View Changed
Filename Size Change
dist/preact.mjs 5 kB +67 B (+1.36%)
ℹ️ View Unchanged
Filename Size
compat/dist/compat.mjs 3.97 kB
debug/dist/debug.mjs 4.19 kB
devtools/dist/devtools.mjs 268 B
hooks/dist/hooks.mjs 1.52 kB
jsx-runtime/dist/jsxRuntime.mjs 875 B
test-utils/dist/testUtils.mjs 472 B

compressed-size-action

@coveralls

coveralls commented Nov 13, 2026 •

Copy link
Copy Markdown

Coverage Status

coverage: 99.857%. remained the same — pending-range-hydration into main

MaxwellCohen added a commit to MaxwellCohen/pracht-dpu that referenced this pull request Nov 17, 2026
…-to-string PR #496

Fixes /parallel hydration mismatches.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@JoviDeCroock
JoviDeCroock marked this pull request as ready for review November 18, 2026 09:22
A range the server is still streaming opens with $s? and holds the
fallback, a range it gave up on opens with $s!. When the client rendered
the content there, hydration adopted the fallback's elements with their
attributes, or elements of a later sibling.

The boundary's children now only get that range to adopt from and diff
the attributes of what they adopt.
Same behaviour, 24 B gzip less in core.

- rangeEnd() notes on the list it collects whether the range holds a
  fallback, so the resume block and the boundary branch don't each spell
  out the marker test.
- rangeEnd() collects a start node that isn't a comment, so the resume
  block doesn't branch on the node type.
- rangeEnd() collects the closing marker too: the boundary branch takes
  the list as it is, the resume block pops the marker off.
- The boundary branch collects into `tmp`, so there is nothing to reset
  when it leaves the range alone, and keeps what followed the range
  without wrapping it in an array.
Removing a prop that maps to a DOM property leaves the attribute empty
(`id=""`), so the tests compared against markup they can't get.
@JoviDeCroock
JoviDeCroock force-pushed the pending-range-hydration branch from 1ceeb74 to 63e1c81 Compare November 18, 2026 12:18
@JoviDeCroock
JoviDeCroock merged commit 7f8004b into main Nov 18, 2026
13 checks passed
@JoviDeCroock
JoviDeCroock deleted the pending-range-hydration branch November 18, 2026 18:17
MaxwellCohen added a commit to MaxwellCohen/pracht-dpu that referenced this pull request Nov 18, 2026
- Bump preact to a build of preactjs/preact#5360 head 63e1c81
- Boot the client as soon as #pracht-state is parsed so hydration meets
  boundaries that are still streaming (opt out with ?late-hydrate)
- Add hydration probes and seven edge cases: fallback attributes, next
  sibling adoption, $s! from a render error and a mid-stream rejection,
  client-null content, nested pending ranges, and 400 boundaries landing
  while the client is suspended

Co-Authored-By: Claude Opus 5.5
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants